package com.longxiao.manager.web;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

public abstract class BaseController {
	protected final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@ExceptionHandler(value = {Exception.class})
	public Object exceptionHandler(Exception e) {
		logger.error("系统异常：" + e.getMessage(),e);
		return null;
	}
	
	protected void initParam(HttpServletRequest request, ModelAndView mav) {
		Enumeration<String> names = request.getParameterNames();
		for(;names.hasMoreElements();) {
			String n = names.nextElement();
			mav.addObject(n, request.getParameter(n));
		}
	}
}
